import request from '@/utils/request'

export function login(username, password) {
  return request({
    url: '/api/token/',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: 'username=' + username + '&password=' + password
  })
}

export function refreshToken(refresh_token) {
  return request({
    url: '/api/refresh/',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: 'grant_type=refresh_token&refresh_token=' + refresh_token + '&client_id=w8j8W22qDpUeZLvnBdkBTyYo5XmD9OSjgFhvcdEC&client_secret=jgQSChDvi6hwIVBvCLBeJIg4mX8ocGuyzEZ6MyFEembug6465ZRvqAQrPQ2xjYYchxKbH7V1XAX43Rc6keUe9FHN6i9sv3zEMZ7x9f0LHOq5GEUJrHyao8YcFgvI1cgf'
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}
